package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.apis.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(value = "频道管理",tags = "channel",description = "频道管理的api接口")
public class AdChannelController implements AdChannelControllerApi {

    @Autowired
    AdChannelService adChannelService;

    /**
     * 查询频道列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @Override
    @ApiOperation(value = "频道分页查询",notes = "根据名称分页查询频道信息")
    @ApiImplicitParam(name = "dto",type = "ChannelDto",value = "分页及名称信息")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto dto) {
        return adChannelService.findByNameAndPage(dto);
    }


    //添加
    @PostMapping("/save")
    @Override
    public ResponseResult save(AdChannel adchannel) {
        return adChannelService.insert(adchannel);
    }

    //修改
    @Override
    @PostMapping("/update")
    public ResponseResult update(AdChannel adChannel) {
        return adChannelService.update(adChannel);
    }

    @Override
    @GetMapping("/del/{id}")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adChannelService.deleteById(id);
    }


}
